/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package wollongongtemp.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

/**
 *
 * @author Wade
 */
@Entity
@Table(name = "CUSTOMERS")
@NamedQueries({
    @NamedQuery(name = "findCustomersByName", query = "SELECT c FROM Customer c WHERE c.name LIKE :custName"),
    @NamedQuery(name = "findCustomerByID", query = "SELECT c FROM Customer c WHERE c.id = :custID"),
    @NamedQuery(name = "getAllCustomer", query = "SELECT c FROM Customer c ORDER BY c.name")
})
public class Customer implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @NotNull
    @Column(unique = true, nullable = false)
    private String name;
    private String address;
    @NotNull
    private String contactName;
    private String telephone;
    private String fax;
    private String mobile;
    @NotNull
    //@Column(unique = true, nullable = false)
    private String email;
    private String note;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "customer")
    private Set<Request> requests = new HashSet<Request> ();

    public Customer() {
    }

    public Customer(String name, String address, String contactName, String telephone, String fax, String mobile, String email, String note) {
        this.name = name;
        this.address = address;
        this.contactName = contactName;
        this.telephone = telephone;
        this.fax = fax;
        this.mobile = mobile;
        this.email = email;
        this.note = note;
    }

    public Set<Request> getRequests() {
        return requests;
    }

    public void setRequests(Set<Request> requests) {
        this.requests = requests;
    }
    
    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getFax() {
        return fax;
    }

    public void setFax(String fax) {
        this.fax = fax;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getContactName() {
        return contactName;
    }

    public void setContactName(String contactName) {
        this.contactName = contactName;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String Address) {
        this.address = Address;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Customer)) {
            return false;
        }
        Customer other = (Customer) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "wollongongtemp.entity.Customer[id=" + id + "]";
    }

}
